
CommonUtils.regNamespace("inter", "index");

inter.index = (function(){
	
	var _queryInterError = function(){
		if($("#showtotal").hasClass("btn-white")){
			$("#showtotal").removeClass("btn-white").addClass("btn-primary");
			$("#showfail").removeClass("btn-primary").addClass("btn-white");
		}
		var querytext = $("#querytext").val();
		var path= contextPath+"/report/queryInterError";
		var params = {"querytext":querytext};
		$.ajax({
	        type:"POST",
	        url:path,
	        data:JSON.stringify(params),
	        contentType:"application/json; charset=utf-8",
	        dataType: "html",
	        async:false,
	        success:function(respone){
	        	if(respone){
	        		$("#errorListDiv").html(respone);
	        	}else{
	        		alert("上传apk失败");
	        	}
	        },error:function(respone){
	            alert("请求发生错误:"+respone);
	        }
	    });
	}

	
	var _showInterFailError = function(){
		if($("#showfail").hasClass("btn-white")){
			$("#showfail").removeClass("btn-white").addClass("btn-primary");
			$("#showtotal").removeClass("btn-primary").addClass("btn-white");
		}
		var path= contextPath+"/report/showInterFailError";
		var params = {"resultStatus":"101"};
		$.ajax({
	        type:"POST",
	        url:path,
	        data:JSON.stringify(params),
	        contentType:"application/json; charset=utf-8",
	        dataType: "html",
	        async:false,
	        success:function(respone){
	        	if(respone){
	        		$("#errorListDiv").html(respone);
	        	}else{
	        		alert("上传apk失败");
	        	}
	        },error:function(respone){
	            alert("请求发生错误:"+respone);
	        }
	    });
	}
var _getUnitReportDetail = function(interfaceId){
		
	}
	var _getInterReportDetail = function(interfaceId){
			var params = {
				"interfaceId":interfaceId
				};
			var path = contextPath+"/report/getInterReportDetail";
			$.ajax({
	        type:"POST",
	        url:path,
	        data:JSON.stringify(params),
	        contentType:"application/json; charset=utf-8",
	        dataType: "html",
	        async:false,
	        success:function(respone){
	        	if(respone){
	        		$("#wrapper-content").html(respone);
	        	}else{
	        		alert("登录失败");
	        	}
	        },error:function(respone){
	            alert("请求发生错误:"+respone);
	        }
	    });
	}
	return {
		queryInterError:_queryInterError,
		showInterFailError:_showInterFailError,
		getUnitReportDetail:_getUnitReportDetail,
		getInterReportDetail:_getInterReportDetail
	};
})();

$(function () {
	var pieChart = echarts.init(document.getElementById("interface-pie-type"));
	//分装data数据
	var data = new Array();
	var typedesc = new Array();
	var typeList = JSON.parse(typeStr);
	$.each(typeList,function(index,list){
		var param = {value:list.typenum,name:list.error_status};
		data.push(param);
		typedesc.push(list.error_type_desc);
	})
	console.log("data:"+data);
    var pieoption = {
        title : {
            text: '接口问题类型',
            x:'center'
        },
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        calculable : true,
        series : [
            {
                name:'问题类型',
                type:'pie',
                radius : '55%',
                center: ['50%', '60%'],
                data:data
            }
        ]
    };
    pieChart.setOption(pieoption); 
    
    var pieChart = echarts.init(document.getElementById("interface-pie-reason"));
    var pieoption = {
        tooltip : {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },
        legend: {
            orient : 'vertical',
            x : 'left',
            data:['Java Runtime error','NDK error:SIGSEGV','Java Runtime error:java.lang.OutOfMemoryError','code fail','error']
        },
        calculable : true,
        series : [
            {
                name:'问题原因',
                type:'pie',
                radius : '55%',
                center: ['50%', '60%'],
                data:[
                    {value:335, name:'Java Runtime error'},
                    {value:310, name:'NDK error:SIGSEGV'},
                    {value:234, name:'Java Runtime error:java.lang.OutOfMemoryError'},
                    {value:135, name:'code fail'},
                    {value:136, name:'error'}
                ]
            }
        ]
    };
    //pieChart.setOption(pieoption); 
    
    doption = {
    	    title : {
    	        text: '问题原因',
    	        x:'center'
    	    },
    	    tooltip : {
    	        trigger: 'item',
    	        formatter: "{a} <br/>{b} : {c} ({d}%)"
    	    },
    	    legend: {
    	        x : 'center',
    	        y : 'bottom',
    	        data:['Java Runtime error','NDK error:SIGSEGV','Java Runtime error:java.lang.OutOfMemoryError','code fail','error']
    	    },
    	    calculable : true,
    	    series : [
    	        {
    	            name:'异常用例数',
    	            type:'pie',
    	            radius : [15, 75],
    	            center : ['45%', 130],
    	            roseType : 'radius',
    	            width: '30%',       // for funnel
    	            max: 40,            // for funnel
    	            itemStyle : {
    	                normal : {
    	                    label : {
    	                        show : false
    	                    },
    	                    labelLine : {
    	                        show : false
    	                    }
    	                },
    	                emphasis : {
    	                    label : {
    	                        show : true
    	                    },
    	                    labelLine : {
    	                        show : true
    	                    }
    	                }
    	            },
    	            data:[
    	                {value:335, name:'Java Runtime error'},
                    {value:310, name:'NDK error:SIGSEGV'},
                    {value:234, name:'Java Runtime error:java.lang.OutOfMemoryError'},
                    {value:135, name:'code fail'},
                    {value:136, name:'error'}
    	            ]
    	        }
    	    ]
    	};
    	                    
    	
    	pieChart.setOption(doption); 
});